package 每日一题;

public class Date1201 {

    /**
     * 自解：暴力解
     * @param nums
     * @param target
     * @return
     */
    public int[] searchRange(int[] nums, int target) {
        if (nums==null){
            return new int[]{-1,-1};
        }
        int[] result = new int[]{-1,-1};

        int count=0;
        for (int i=0;i<nums.length;i++){
            if (nums[i] == target){
                if (result[1] !=-1){
                    result[1] = i;
                }else {
                    result[0]=i;
                    result[1]=i;
                }

            }
        }
        return result;
    }

    /**
     * 折半查找---暂定
     */
    public int[] searchRange1(int[] nums, int target) {
        if (nums==null){
            return new int[]{-1,-1};
        }
        int[] result = new int[]{-1,-1};
        int i=0;
        int j= nums.length;

        if (target < nums[nums.length / 2]){
            i= nums.length /2;
        }
        return result;
    }
}
